package com.ellricky.teacher.ui.mycourse.experience

import android.view.View
import android.widget.AdapterView
import com.andr.common.http.callback.BaseCallback
import com.andr.common.ui.adapter.BaseRecyclerAdapter
import com.andr.common.ui.mvp.BasePresenter
import com.ellricky.baselib.http.callback.EListCallback
import com.ellricky.baselib.ui.base.BaseRefreshActivity
import com.ellricky.baselib.util.EAppUtil
import com.ellricky.teacher.API_EXPERIENCE_SUMUP_LIST
import com.ellricky.teacher.R
import com.ellricky.teacher.SumupAdapter
import com.ellricky.teacher.TcSumupEntity

class ExperienceListActivity : BaseRefreshActivity<Void, BasePresenter<Void>, TcSumupEntity>() {

    override fun initUIView() {
        super.initUIView()
        mTvTitle.text = getString(R.string.tc_experience_sum_up)
        setRightBtn(0)
    }

    override fun getResponseCallback(): BaseCallback {
        return object : EListCallback<TcSumupEntity>(this) {
            override fun onSuccess(data: MutableList<TcSumupEntity>?, msg: String?) {
                dataSource = data
                rvView.onLoadFinish(dataSource, refresh)
            }

            override fun onErrorCode(code: String, msg: String) {
                super.onErrorCode(code, msg)
                rvView.onRefreshFailed(refresh)
            }

            override fun onHttpError(code: String, msg: String) {
                super.onHttpError(code, msg)
                rvView.onRefreshFailed(refresh)
            }
        }

    }

    override fun getRvAdapter(): BaseRecyclerAdapter<TcSumupEntity> {
        return SumupAdapter()
    }


    override fun getUrlPath(): String {
        return API_EXPERIENCE_SUMUP_LIST
    }

    override fun onItemClick(adapterView: AdapterView<*>?, view: View?, position: Int, l: Long) {
        super.onItemClick(adapterView, view, position, l)
        val sumupEntity = adapter[position]
        EAppUtil.jumpPageWithId(this, ExperienceDetailActivity::class.java, sumupEntity.id)

    }


    override fun onClickBtnRight() {
        super.onClickBtnRight()
        EAppUtil.jumpPageWithNoParam(this, ExperienceAddActivity::class.java)
    }
}
